#ifndef DISPLAY_HANDLER_H
#define DISPLAY_HANDLER_H

#include <QWidget>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QDateTime>

#include "display_shared_settings.h"
#include "main_area_paint.h"
#include "leftbarpaint.h"
#include "right_bar_paint.h"
#include "psd_chart_painter.h"
#include "top_bar_paint.h"
#include "timeareapaint.h"

#include "global_defines.h"
#include "calculate/cal_wind_avg.h"

class Display_Handler : public QWidget
{
public:
    Display_Handler(QWidget *parent = nullptr);
    void create_central_widget();
    void update_hight_num();
    int get_display_mode();
    void update_setting(SOFTWARESETTINGS newsettings);
    void refreshdisp();

    Main_Area_Paint *main_area;
    PSD_Chart_Painter *psd_chart_area;
    QDateTime last_avg_time;

public slots:
    void update_psd_display(double *psd_data, unsigned int nRB_ovlp, unsigned int totaldatanum);
    void update_wind_display(double *hVelocity, double *hAngle, double *vVelocity, double *snr, bool *data_valid, uint nRB);

private:
    double scaleUI(double spec);
    void moveEvent(QMoveEvent * event);
    void resizeEvent(QResizeEvent *event);
    void set_display_mode(int new_display_mode);
    void findmaxmin(uint datanum);
    void update_scale_ui(double newscaleui);

    SOFTWARESETTINGS mysetting;

    //Left_Bar_Textb *left_bar_area;
    LeftBarPaint * left_bar_area;
    Right_Bar_Paint *right_bar_area;
    Top_Bar_Paint *top_bar_area;
    TimeAreaPaint *time_area;
    QHBoxLayout *center_h;
    QVBoxLayout *center_v;
    QGridLayout *center;

    int avg_num_count = 0;
};

#endif // DISPLAY_HANDLER_H
